//
//  BaseModel.m
//  UI_19 视图切换
//
//  Created by leilei on 16/3/8.
//  Copyright © 2016年 www.lei.com. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel
//四  4.3KVC 赋值容错()
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}


//五. 基类
- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        // KVC赋值
        [self setValuesForKeysWithDictionary:dic];
        
    }
    return self;
    
}


//五.便利构造器(通用格式的)
+ (instancetype)modelWithDic:(NSDictionary *)dic
{
    id m = [[[self class] alloc] initWithDic:dic];
    return m;
}


//六.转化
+ (NSMutableArray *)transformWithArray:(NSArray *)arr
{
    //创建空数组
    NSMutableArray *mArr = [NSMutableArray array];
    //便利传入参数
    for (NSDictionary *dic in arr) {
        //创建对象
        id m = [[self class] modelWithDic:dic];
        //添加到数组中
        [mArr addObject:m];
    }
    return mArr;
    
}



@end
